<?php
class PublicAction extends Action{
	public function verify(){
		import("ORG.Util.Image");
		Image::buildImageVerify();
	}
	
	function login(){
		/*if(session("verify")!=md5($this->_post("verify"))){
		 $this->error("验证码错误");
		}*/
		if($this->_post('uid')==''){
			$this->error("用户名不能为空");
		}
		if($this->_post('password')==''){
			$this->error('密码不能为空');
		}
		$user=M('Adm');
		$where['uid']=$this->_post('uid');
		$where['password']=$this->_post('password');
		$list=$user->where($where)->select();
		if($list){
			session("uid",$this->_post('uid'));
			session("username",$list[0]['uname']);
			session("password",$list[0]['password']);
			session("province",$list[0]['province']);
			session("level",$list[0]['level']);
			session("type",$list[0]['type']);
			session("logintime",time());
			$data['logins']=array('exp','logins+1');
			$data['loginip']=get_client_ip();
			$data['lastlogin']=Date("Y-m-d H:i:s",time());
			$user->where($where)->data($data)->save();
			$this->success("登录成功","/admin/Main");
		}else{
			$this->error("用户名或密码错误");
		}
	}
	
	function layout(){
		session(null);
		$this->display("Pulbic:login");
	}
}